#include<iostream>
using namespace std;
const int N = 1e6 + 10;
long long f[N];
int main()
{
    int m , n;
    cin >> m >> n;
    for(int i = 1; i <= m; i++)
        {
            long long x;
            cin >> x;
            f[i] = f[i - 1] + x;
        }
        
    while(n--)
    {
        int l, r;
        cin >> l >> r;
        cout << f[r] - f[l - 1] << endl;
    }
    return 0;
}
